package Exercise1;

import javax.swing.*;

public class SwingTest {
    public static void main(String args[])
    {
        String str_menu[] ={"查看","编辑","帮助"};
        String str_menuitem[][]={{"科学型","函数型","什么型"},{"赋值","剪切"},{"背景","查询"}};
        Calu calu = new Calu(str_menu, str_menuitem);

    }
    public static JMenuBar Myuilt(String str_menu[],String str_menuitem[][])
    {
        JMenuBar bar = new JMenuBar();
        for (int i = 0; i < str_menu.length; i++) {
            JMenu menu = new JMenu();
            for (int j = 0; j < str_menuitem[i].length; j++) {
                JMenuItem menuItem = new JMenuItem(str_menuitem[i][j]);
                menu.add(menuItem);
            }
            bar.add(menu);
        }
        return bar;
    }
}

class Calu extends JFrame
{
    public Calu(String str_menu[],String str_menuitem[][]) {
        JFrame jFrame = new JFrame("计算器");
        jFrame.setBounds(40,30,400,300);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        SwingTest.Myuilt(str_menu,str_menuitem);
        jFrame.setVisible(true);
    }
}